package com.yoda.mall.mysql.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yoda.mall.api.CouponProductRelationApi;
import com.yoda.mall.model.entity.sms.CouponProductRelation;
import com.yoda.mall.mysql.mapper.CouponProductRelationMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class CouponProductRelationApiImpl implements CouponProductRelationApi {
    @Autowired
    private CouponProductRelationMapper couponProductRelationMapper;

    @Override
    public void addCouponProductRelation(CouponProductRelation couponProductRelation) {
        couponProductRelationMapper.insert(couponProductRelation);
    }

    @Override
    public void deleteCouponProductRelationByCouponId(Long id) {
        LambdaQueryWrapper<CouponProductRelation> lqw = new LambdaQueryWrapper();
        lqw.eq(CouponProductRelation::getCouponId,id);
        couponProductRelationMapper.delete(lqw);
    }

    @Override
    public List<CouponProductRelation> getCouponProductRelationListByCouponId(Long id) {
        LambdaQueryWrapper<CouponProductRelation> lqw = new LambdaQueryWrapper();
        lqw.eq(CouponProductRelation::getCouponId,id);
        return couponProductRelationMapper.selectList(lqw);
    }
}
